<?php

use yii\helpers\Url;
use yii\helpers\Html;
use yii\bootstrap\Modal;
use kartik\grid\GridView;
use backend\assets\CrudAsset;
use backend\assets\ZtreeAsset;
use johnitvn\ajaxcrud\BulkButtonWidget;
use backend\components\widgets\ztree\ZtreeWidget;
use backend\components\widgets\BulkMoveWidget;
/* @var $this yii\web\View */
/* @var $searchModel backend\module\content\models\ArticleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('common', 'Article Manage');
$this->params['breadcrumbs'][] = $this->title;

CrudAsset::register($this);
?>
<div class="col-lg-2">
    <?=
    ZtreeWidget::widget([
        'data' => $ztreeNode,
    ]);
    ?>
</div>
<div class="article-index col-lg-10">
    <div id="ajaxCrudDatatable">
        <?=
        GridView::widget([
            'id' => 'crud-datatable',
            'dataProvider' => $dataProvider,
            'pjax' => true,
            'columns' => require(__DIR__ . '/_columns.php'),
            'toolbar' => [
                ['content' =>
                    Html::a('<i class="glyphicon glyphicon-plus"></i>', ['create', 'catid' => $catid], ['data-pjax' => '0', 'title' => 'Create new Articles', 'class' => 'btn btn-default']) .
                    Html::a('<i class="glyphicon glyphicon-search"></i>', 'javascript:;', ['title' => Yii::t('common', 'Search'), 'class' => 'btn btn-default', 'data-toggle' => "modal", 'data-target' => "#searchModal"]) .
                    Html::a('<i class="glyphicon glyphicon-repeat"></i>', [''], ['data-pjax' => 1, 'class' => 'btn btn-default', 'title' => Yii::t('common', 'Reset')]) .
                    '{toggleData}' .
                    '{export}'
                ],
            ],
            'striped' => true,
            'condensed' => true,
            'responsive' => true,
            'panel' => [
                'type' => 'primary',
                'heading' => '<i class="glyphicon glyphicon-list"></i> ' . Yii::t('common', 'Articles listing') . ($breadcrumb ? '&nbsp;<i class="fa fa-caret-right"></i>&nbsp;' . $breadcrumb : ''),
                'before' => '<em>* </em>' . Yii::t('common', 'Resize table columns just like a spreadsheet by dragging the column edges.'),
                'after' => BulkButtonWidget::widget([
                    'buttons' => Html::a('<i class="glyphicon glyphicon-trash"></i>&nbsp; ' . Yii::t('common', 'Delete All'), ["bulk-delete"], [
                        "class" => "btn btn-danger btn-xs",
                        'role' => 'modal-remote-bulk',
                        'data-confirm' => false, 'data-method' => false, // for overide yii data api
                        'data-request-method' => 'post',
                        'data-confirm-title' => Yii::t('common', 'Are you sure?'),
                        'data-confirm-message' => Yii::t('common', 'Are you sure want to delete this item')]),
                ]) .
                BulkMoveWidget::widget([
                    'select2Data' => $select2Data,
                    'controller'=>'article',
                ]).'<div class="clearfix"></div>'
            ]
        ])
        ?>
    </div>
</div>
<?php
Modal::begin([
    "id" => "searchModal",
    "footer" => "", // always need it for jquery plugin
])
?>
<?= $this->render("_search", ["model" => $searchModel, 'catid' => $catid]) ?>
<?php Modal::end(); ?>
<?php
Modal::begin([
    "id" => "ajaxCrudModal",
    "footer" => "", // always need it for jquery plugin
    "size" => Modal::SIZE_LARGE,
])
?>
<?php Modal::end(); ?>
